﻿@using MvcAtletIS.Helpers;
@model IEnumerable<MvcAtletIS.Models.Articles>
@{
    ViewBag.Title = "Články";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@section head {

    <link href="@Url.Content("~/footable/css/footable.core.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/footable/css/footable.standalone.css")" rel="stylesheet" type="text/css" />
  
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js" type="text/javascript"></script>
    <script src="@Url.Content("~/footable/js/footable.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/footable/js/footable.sort.js")" type="text/javascript"></script>
    
    <script type="text/javascript">
        $(function () {
            $("table").footable();
        });
    </script>
}

<h2>Články: @ViewBag.ParentCategory.Name</h2>

<p>
    Počet hlavných článkov: @Model.Where(a => a.Active == true & a.Top == true).Count() <br />
    Počet ďalších zobrazených článkov: @Model.Where(a => a.Active == true & a.Top == false).Count()
</p>

<p> 
    Vyberte rok a mesiac, pre ktorý chcete zobraziť prehľad článkov. 
</p>

@using (Html.BeginForm())
{   
    <div class="filter-frame">
        
        <div class="filter-item">
            <div class="editor-label">
                Rok
            </div>
            <div class="editor-field">
                @Html.DropDownList("Year", null, "Vyberte rok", new { onchange = "this.form.submit();" })
            </div>
        </div>
    
        <div class="filter-item">
            <div class="editor-label">
                Mesiac
            </div>
            <div class="editor-field">
                @Html.DropDownList("Month", null, "Vyberte mesiac", new { onchange = "this.form.submit();" })
            </div>
        </div>

    </div>
}

<p>
    @Html.ActionLink("< Administrácia", "Index", "Home", new { area = "Admin" }, null) |
    @Html.ActionLink("Pridať nový článok", "Create", new { CategoryId = ViewBag.ParentCategory.ID })
</p>

<table class="footable table toggle-arrow-tiny">
    <thead>
        <tr>
            <th width="50" data-class="expand" data-type="numeric">
                ID
            </th>
            <th data-type="numeric">
                Dátum
            </th>
            <th>
                Názov
            </th>
            <th data-hide="phone,tablet">
                Perex
            </th>
            <th data-hide="phone,tablet">
                Miesto
            </th>
            <th data-hide="phone,tablet">
                Editor
            </th>
            <th width="50px" data-sort-ignore="true">
                Aktívny
            </th>
            <th width="50px" data-sort-ignore="true">
                Hlavný
            </th>
            <th width="100px" data-sort-ignore="true"></th>
        </tr>
    </thead>
    <tbody>
    @foreach (var item in Model) 
    {
        <tr>
            <td align="center">
                @Html.DisplayFor(modelItem => item.ID)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Date)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Title)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Perex)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.City)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Editor)
            </td>
            <td align="center">
                @Html.DisplayFor(modelItem => item.Active)
            </td>
            <td align="center">
                @Html.DisplayFor(modelItem => item.Top)
            </td>
            <td>
                @Html.ImageActionLink(Url.Content("~/Content/icons/preview.gif"), "", "Details", new { id = item.ID }, new { title = "Zobraziť", border = 0, hspace = 2 }) |
                @Html.ImageActionLink(Url.Content("~/Content/icons/edit.gif"), "", "Edit", new { id = item.ID }, new { title = "Editovať", border = 0, hspace = 2 }) |
                @Html.ImageActionLink(Url.Content("~/Content/icons/delete.gif"), "", "Delete", new { id = item.ID }, new { title = "Zmazať", border = 0, hspace = 2 })
            </td>
        </tr>
    }
    </tbody>
</table>